import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
// rem适配
import './utils/rem.js'
// 统一化CSS
import 'normalize.css/normalize.css'
import './assets/css/layout.scss'
import './assets/css/custom.scss'
import SvgIcon from './components/SvgIcon.vue'
// element-plus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
// 自定义全局组件
import Empty from '@/components/no-data'
// 引入moment
import moment from 'moment'
// echarts
import * as echarts from 'echarts';
// import 'echarts-gl'
import jquery from './assets/jq';
import "animate.css"
const app = createApp(App)
// 挂载 moment
app.config.globalProperties.$ = jquery
app.config.globalProperties.$moment = moment
app.config.globalProperties.$echarts = echarts
app.use(store).use(router).use(ElementPlus).mount('#app')
app.component('Empty', Empty)
app.component('SvgIcon', SvgIcon)
// import {getSession} from '@/http/storage';
let lifeData = []

// 是否有菜单权限
const hasMenuPermission = userPermission => {
	try{
		lifeData = getSession('menuList');
	}catch(e){
		
  }
  let userPermissionList = Array.isArray(userPermission) ? userPermission : [userPermission];
  return userPermissionList.some(e => lifeData.includes(e));
};


//菜单权限指令
app.directive('mauth', {
    inserted: (el, binding, vnode) => {
        if (!hasMenuPermission(binding.value) && binding.value) {
			    // el.parentNode.removeChild(el)
        }
    }
});


// 全局判断方法
app.config.globalProperties.$_mauth = hasMenuPermission;
